#include "stdafx.h"
#include "MainProImpl.h"
#include "CommHandler.h"
#include "Manager.h"
#include "UnitItem.h"
#include "LocalFileMgr.h"
#include "StepListHandle.h"

int CMainProImpl::SetSepCapLight( const char* szMidIp, WORD wMode, short nCount, short chlNo[600] )
{
	int nRet = -1;
	CUnitItem* pUnit = g_BtsMgr.GetUnitItem(szMidIp);
	if (pUnit)
	{
		WORD nDevId = pUnit->GetUnitNo();
		stControlChlInfo ctlInfo;
		ctlInfo.nChlCount = nCount;
		memcpy(ctlInfo.chlNo , chlNo, sizeof(short)*nCount);
		g_CommHandler.GetClientNet().SepCapLight(nDevId,wMode,ctlInfo);
	}

	return nRet;
}

int CMainProImpl::CopySourceData( const BTS_DATA_TEST btsTes, const char* szDesDir )
{
	BTS_DATA_CHL chl;
	chl.unit_id = btsTes.unit_id;
	chl.chl_id = btsTes.chl_id;
	time_t tStart = btsTes.startTime/1000;
	CString strTime = CStepListHandle::FormatUnixTime(tStart, 3);
	CString strFile;
	int nRet = -1;
	if (g_FileMgr->GetFile(strFile, strTime, chl, btsTes.batch) >= 0)
	{
		int nFileNameBegin = strFile.ReverseFind(_T('\\'));
		CString strFileName = strFile.Right(strFile.GetLength()-nFileNameBegin);
		CString strTmpBdf = CA2W(szDesDir);
		nRet = ::CopyFile(strFile, strTmpBdf+strFileName, FALSE);
	}

	return nRet;
}
